import json
from kafka import KafkaProducer

producer = KafkaProducer(bootstrap_servers='1.13.7.99:9092')

msg_dict = {
            "sleep_time": 10,
            "db_config": {
                "database":"test_1",
                "host":"xxxx",
                "user":"root",
                "password":"root"
            },
            "table": "msg",
            "msg": "Hello World"
        }
msg = json.dumps(msg_dict)
msg2="aabbccddeeffaagg"
producer.send('test',msg,partition=0)

#producer.send(topic='userTest',value=msg.encode('utf-8'),headers=None,partition=0,timestamp_ms=None)

producer.close()


# class KafkaProducer:
#     pass